# This is like SecondSharedExample, only we start up 10
# processes.  Working together they should count up to 100.
# They usually don't.

from multiprocessing import *
import time

def F(r):
    # This increments r 10 times
    for i in range(0, 10):
        x = r.value
        y = x+1
        r.value = y
        print( "Process %d set r to %d" % (current_process().pid, r.value))
        time.sleep(0.05)  # to model steps that take longer

def main():
    r = RawValue("i", 0)
    L = []
    for i in range(10):
        p = Process(target=F, args = (r,))
        L.append(p)
    for p in L:
        p.start()
    

if __name__ == "__main__":
    main()
    input()

